home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.orig.lzh / doc / interface < prev    next >
Text File  |  1989-06-27  |  16KB  |  352 lines

  1. .DA "9 June 1989"
  2. .TL
  3. The Interface Between C News And The Outside World
  4. .AU
  5. Henry Spencer
  6. .AI
  7. Dept. of Zoology
  8. University of Toronto
  9. .SH
  10. Intro and Generalities
  11. .PP
  12. C News relates to the ``outside world'',
  13. the system it is installed on, in a number of ways.
  14. This document attempts to enumerate them and explain what goes on.
  15. .PP
  16. In general, C News attempts to rely only on ``common basic Unix'',
  17. and in particular it is not particularly BSD-specific or System-V-specific.
  18. Specifically,
  19. it makes no use of ornate locking mechanisms, silly interprocess-communication
  20. schemes, peculiar networking primitives,
  21. extensions to C, or other annoyances.
  22. .SH
  23. Directories And Userids
  24. .PP
  25. Most of the components of C News live in \fI/usr/lib/newsbin\fR,
  26. with control files in \fI/usr/lib/news\fR and spooling areas
  27. (for current news, inbound traffic, and outbound traffic) in
  28. \fI/usr/spool/news\fR.
  29. See the document
  30. \fIDirectory Layout and PATH in C News\fR
  31. for elaboration on the structure,
  32. \fIFiles in /usr/lib/news (aka NEWSCTL)\fR for a summary of control files,
  33. and
  34. \fIConfiguration Mechanisms in C News\fR
  35. for how to change the locations of the directories.
  36. .PP
  37. There is an extensive subdirectory structure under \fI/usr/lib/newsbin\fR,
  38. with only a few heavily-used utilities in the top-level directory.
  39. In the following,
  40. programs not explicitly described as going elsewhere are all under there
  41. somewhere.
  42. .PP
  43. C News's spool areas and major control files need to be owned by a
  44. specific userid, normally \fInews\fR.
  45. (We believe that nothing except some of the Makefiles knows this name.)
  46. We suggest that this userid should not own anything else on the system.
  47. The programs in \fI/usr/lib/newsbin\fR can be
  48. owned by \fIbin\fR (or anyone else) except for those that need to be setuid.
  49. (On our systems the non-setuid ones are owned by \fIbin\fR.)
  50. .SH
  51. Unix Utilities
  52. .PP
  53. C News requires a fairly complete Unix or equivalent.
  54. (We take no position on whether 4BSD, or System V, is Unix or not;
  55. our private opinion is that neither truly deserves the name any more,
  56. although we occasionally change our minds about which is less deserving.)
  57. (Note also that ``Unix'' is used here as an abbreviation for
  58. \fBThe UNIX Operating System\fR\(rg,
  59. a registered trademark of AT&T;
  60. we acquired our bad habits and incorrect capitalization from
  61. Unix [sic] documentation supplied by the Bell System in the mid-1970s.)
  62. .PP
  63. In particular, C News relies heavily on shell files.
  64. ``Shell'' here means, of course, the standard shell, written by
  65. Steve Bourne.
  66. If your \fI/bin/sh\fR is not a Bourne shell or \fIvery\fR good imitation,
  67. you're in trouble.
  68. Note, in particular, that some old versions of the Korn shell differ from
  69. the Bourne shell in some important details of quoting behavior, and
  70. we \fIknow\fR this causes problems with C News.
  71. You need a standard shell.
  72. .PP
  73. To the best of our ability, all our shell files begin with ``#!\ /bin/sh''.
  74. If your shell misinterprets this as a request to run the C shell, you're
  75. in trouble.
  76. If your shell doesn't know about ``#'' comments at all, you're in trouble.
  77. We hope that no modern shell makes either of these mistakes.
  78. .PP
  79. We believe that none of our stuff relies on relatively modern shell features
  80. like shell functions or \fIgetopts\fR (as distinct from \fIgetopt\fR).
  81. If \fItest\fR and \fIecho\fR are not built-in commands in your shell,
  82. efficiency will suffer
  83. but everything should still run.
  84. It's possible that a few obscure things will break if your shell does not
  85. support ``['' as a synonym for \fItest\fR, although we try to avoid this usage.
  86. .PP
  87. Within the shell files, C News makes heavy use of a wide variety of Unix
  88. utilities, notably \fIsed\fR and \fIawk\fR.
  89. Any \fIawk\fR should do; in particular, nothing needs the ``new \fIawk\fR''
  90. (we don't run it yet).
  91. Although we have tried to avoid it, it is possible that some things depend
  92. on \fIawk\fR recognizing ``\et'' inside strings, which very old \fIawk\fRs
  93. didn't.
  94. .PP
  95. If your Unix does not put all standard Unix programs in
  96. the standard directories\(em\fI/bin\fR and
  97. \fI/usr/bin\fR\(emyou will need to modify C News's default PATH to include
  98. whatever bizarre directories are involved.
  99. See the \fIConfiguration Mechanisms\fR document for details.
  100. In particular, for some insane reason, 4BSD relocated a few standard
  101. utilities like \fIwc\fR to \fI/usr/ucb\fR, which causes trouble
  102. (and not just to C News!).
  103. We simply put some links in \fI/usr/bin\fR to fix this on our systems,
  104. and this is what we recommend you do, but if you can't, you'll have to
  105. change the PATH.
  106. .PP
  107. Several parts of C News rely on being able to send mail to an administrative
  108. account (the name of which can be chosen; see \fIConfiguration Mechanisms\fR).
  109. The assumption is that a message, without any RFC822 headers, can be piped
  110. into \fI/bin/mail\fR (or whatever \fImail\fR is first in the PATH)
  111. invoked with a single argument which is the addressee,
  112. and be delivered to the addressee's mailbox intact, possibly embellished
  113. with headers.
  114. That is, with news's standard PATH, if
  115. .DS
  116. echo hi there Joe | mail joe
  117. .DE
  118. does not result in the message ``hi there Joe'' arriving in the mailbox
  119. ``joe'', you're going to have to fake it.
  120. See \fIDirectory Layout\fR for insight on where to put a fake \fImail\fR
  121. so that C News components will use it rather than \fI/bin/mail\fR.
  122. .PP
  123. Similarly, several parts of C News rely on being able to invoke \fIhostname\fR
  124. without arguments, and have it return a single word which is the name of the
  125. CPU the code is running on.
  126. Again, you'll have to fake it if you don't have \fIhostname\fR
  127. or if it outputs something strange.
  128. .PP
  129. Input reception and output batching both want to use the \fIcompress\fR
  130. data-compression program.
  131. \fICompress\fR has been published on Usenet and is shipped with many Unix
  132. systems these days, but if you don't have it, we recommend that you get
  133. it from your neighbors or the \fIcomp.sources.unix\fR archives.
  134. It is possible to configure C News so that it doesn't use \fIcompress\fR
  135. to compress news being transmitted, but you don't want to.
  136. \fICompress\fR is good and it is fast.
  137. .SH
  138. Libraries
  139. .PP
  140. C News is mostly self-contained as far as libraries go.
  141. It does need some things that are not yet universal, like a full set
  142. of string functions (e.g. \fIstrtok\fR);
  143. we provide reasonably portable versions of these for places that lack them.
  144. .PP
  145. One thing that C News needs, because it is both useful
  146. and a user-visible part of B News,
  147. is the \fIdbm\fR library.
  148. AT&T has stupidly omitted it from System V.
  149. We include an emulation or two that are claimed to work reasonably well.
  150. If your system doesn't have a real \fIdbm\fR, however, our recommendation
  151. is that you harass your supplier about it.
  152. .SH
  153. Networking
  154. .PP
  155. (We're talking here about networking in the sense of NFS and all those fun
  156. things, not \fIuucp\fR or TCP/IP.)
  157. C News is designed to run on systems which consist of a conglomeration of
  158. machines on a local network, with only one of them acting as news server.
  159. Be warned, though, that if you're doing this, you need to have \fIrsh\fR
  160. or some reasonably equivalent way of executing a program on another CPU.
  161. If you've only got one machine,
  162. just make sure you \fIdon't\fR have a \fI/usr/lib/news/server\fR file and
  163. forget the whole issue.
  164. .SH
  165. Highly System-Specific Things
  166. .PP
  167. There are two small utilities within C News that are inevitably highly
  168. system-specific and have a high probability of needing changes to match
  169. your system.
  170. Both normally live in \fI/usr/lib/newsbin\fR proper.
  171. .PP
  172. \fISpacefor\fR is invoked by various components of C News to find out
  173. how much disk space is available.
  174. The space margins in it are ones we find reasonable, but you may need
  175. to adjust them.
  176. On an old System V system in particular (one where \fIdf\fR can't be applied
  177. to any directory name, but needs to be given a name in \fI/dev\fR), you
  178. will also probably need to modify the locations to be \fIdf\fRed.
  179. You will also need to fix \fIspacefor\fR if your system's \fIdf\fR yields
  180. results in some strange format or in some strange units.
  181. We believe that we get it right for stock 4BSD,
  182. many (but probably not all) System Vs, modern Irix, and real Unix (Version 7).
  183. Beware introducing major inefficiencies:
  184. \fIspacefor\fR is called a lot.
  185. (Our current one could stand to be faster, in fact.)
  186. .PP
  187. \fIQueuelen\fR is invoked by the batcher to determine how long the current
  188. \fIuucp\fR queues are, so it can judge whether it should suspend batching
  189. of output to a given site.
  190. There is too much diversity in \fIuucp\fRs for us to try to do this for all
  191. possible versions.
  192. We think we get it right for the two most common flavors
  193. (HDB, aka BNU, and old subdirectory versions).
  194. Our versions measure queue length in batches, not bytes,
  195. but it would not be hard to change this:
  196. \fIqueuelen\fR, the \fIbatchparms\fR control file, and the \fIsendbatches\fR
  197. how-many-batches-should-I-try-to-add logic need to agree on the units of
  198. measurement, but (we think) nothing else cares.
  199. .PP
  200. It is just possible that you might have to modify \fInewshostname\fR,
  201. which also lives in \fI/usr/lib/newsbin\fR itself.
  202. \fINewshostname\fR delivers the name which should be applied to the
  203. whole system (not just the particular CPU) for news purposes.
  204. It tries to be fairly clever about different ways of getting the name,
  205. and in particular will take it out of \fI/usr/lib/news/whoami\fR if
  206. that file exists, but if you're doing something odd on a strange system,
  207. changes may be needed.
  208. .SH
  209. Input
  210. .PP
  211. Input from the net via \fIuucp\fR (or equivalent) shows up as batches of
  212. news to be fed to \fIrnews\fR or its obsolete synonym \fIcunbatch\fR.
  213. These two programs normally live in \fI/bin\fR, although nothing in the
  214. code knows about this and they can go elsewhere (one of our systems does this).
  215. Both are simple front ends that invoke \fIinput/newsspool\fR to store the
  216. batch, while taking precautions to report trouble and not to overflow disks.
  217. Neither \fIrnews\fR nor \fIcunbatch\fR needs to be setuid.
  218. .PP
  219. Input via NNTP over the Internet (or equivalent) uses rather different
  220. machinery but ends up creating a saved batch in much the same way as
  221. \fIinput/newsspool\fR does.
  222. .PP
  223. \fIInput/newsspool\fR is a small C program that saves a batch,
  224. writing into a file in \fI/usr/spool/news/in.coming\fR.
  225. It must be able to create files there, and \fIinput/newsrun\fR (see below)
  226. needs to be able to read them and delete them.
  227. This gets a little tricky because \fInewsspool\fR will usually be
  228. run by \fIuuxqt\fR as userid \fIuucp\fR (or something like that),
  229. not as \fInews\fR, which \fInewsrun\fR needs to run as.
  230. The recommended solution is to have
  231. \fInewsspool\fR owned by \fInews\fR and setuid.
  232. An alternative is to give the \fIin.coming\fR directory
  233. the userid of \fInews\fR and the groupid of \fIuucp\fR, or vice versa,
  234. and set permissions so that either can access it.
  235. One of our systems ran that way for a while.
  236. .PP
  237. To actually process incoming news, \fIinput/newsrun\fR gets invoked
  238. to decompress the spooled batches and
  239. feed them to \fIrelay/relaynews\fR (see below).
  240. There is an option for \fInewsspool\fR to invoke
  241. \fInewsrun\fR when a batch is spooled,
  242. but a (usually)
  243. preferable method is to have \fIcron\fR invoke \fInewsrun\fR once an hour.
  244. \fINewsrun\fR does its own locking to prevent multiple occurrences running
  245. simultaneously.
  246. There is a related program, \fIinput/newsrunning\fR, that can be used
  247. to set or clear a flag that stops \fInewsrun\fR;
  248. this may be a useful tactic if \fInewsrun\fR should not run at
  249. certain times.
  250. Both \fInewsrun\fR and \fInewsrunning\fR must be run as \fInews\fR.
  251. .PP
  252. When a user posts news, he (or his news reader) does it by feeding the
  253. article to \fI/bin/inews\fR.
  254. In C News, \fIinews\fR is a complex shell file that attends to preliminaries
  255. and then invokes \fIrelay/relaynews\fR.
  256. \fIInews\fR does not need to be setuid (indeed, we make no use of setuid
  257. shell files at all, since they are grossly insecure).
  258. \fIRelaynews\fR is the heart of C News, the program that actually pulls
  259. batches apart and places articles into the database.
  260. If users are to be able to post news, \fIrelaynews\fR should be owned
  261. by \fInews\fR and setuid.
  262. .SH
  263. News Readers
  264. .PP
  265. C News is fully compatible with B News to any news-reader program that
  266. does not inspect the middle field of \fI/usr/lib/news/history\fR too closely.
  267. Standard B News news readers work fine.
  268. We supply a simple news reader
  269. (written by, and included with permission of, Michael Rourke)
  270. as a naive-user replacement for the B News
  271. \fIreadnews\fR.
  272. More complex programs are preferable for serious news enthusiasts.
  273. We recommend Larry Wall's \fIrn\fR
  274. (which we use, unmodified),
  275. but there are others.
  276. .SH
  277. Output
  278. .PP
  279. \fIRelay/relaynews\fR normally queues up news for transmission to other
  280. systems by appending article names and sizes to batch files
  281. in subdirectories under \fI/usr/spool/news/out.going\fR.
  282. These are then processed by \fIbatch/sendbatches\fR, which should be run
  283. regularly, as \fInews\fR, by \fIcron\fR.
  284. \fISendbatches\fR can be configured to use a variety of transmission
  285. mechanisms, the usual being \fIuux\fR.
  286. .SH
  287. Expiry And Related
  288. .PP
  289. News articles are removed, possibly with archiving to an archive area,
  290. by the expiry subsystem.
  291. \fIExpire/doexpire\fR should be invoked now and then,
  292. as \fInews\fR, by \fIcron\fR.
  293. We suggest nightly.
  294. \fIDoexpire\fR actually invokes \fIexpire/expire\fR to do the dirty work.
  295. .PP
  296. C News \fIexpire\fR does not have an option to rebuild the
  297. \fI/usr/lib/news/history\fR file from scratch,
  298. since that has nothing to do with expiry.
  299. To rebuild \fIhistory\fR,
  300. e.g. if it has been destroyed,
  301. use \fIexpire/mkhistory\fR.
  302. .PP
  303. Some news readers need to have the third field of \fI/usr/lib/news/active\fR
  304. updated occasionally to show the lowest article number still present in each
  305. newsgroup.
  306. Frankly, we think such news readers simply need to be fixed.
  307. C News \fIexpire\fR does not do this updating.
  308. For those who use such news readers, however, \fIexpire/upact\fR will do
  309. such an update.
  310. It should be run as \fInews\fR.
  311. .PP
  312. \fIRelay/relaynews\fR
  313. does not implement the ``Supersedes:'' header, which we loathe
  314. as a crude solution to the wrong problem.
  315. Alas, the network-map distribution in
  316. \fIcomp.mail.maps\fR relies heavily on it.
  317. Our preferred approach is to process map articles as they arrive and
  318. then expire them normally (using \fIexpire\fR's expiry-date-override
  319. features to insist that they expire promptly).
  320. However, for those who don't do this, and don't want to have megabytes
  321. of obsolete map data piling up,
  322. \fIexpire/superkludge\fR will remove superseded files in specified
  323. newsgroups.
  324. It should be run as \fInews\fR by \fIcron\fR, perhaps nightly.
  325. .SH
  326. Reboots and Administration
  327. .PP
  328. If the system crashes, things like locks must be cleaned out if C News
  329. is to function properly after reboot.
  330. \fI/etc/rc\fR, or equivalent, should run \fImaint/newsboot\fR during reboot,
  331. as \fInews\fR.
  332. .PP
  333. Certain log files can grow without bounds if not renamed/removed now and
  334. then.
  335. We recommend running \fImaint/newsdaily\fR once a day.
  336. It tends to logs, keeping a generation or two for use in trouble tracking,
  337. and also sends mail to the news administrator in the event that something
  338. funny has happened.
  339. .PP
  340. In general, C News does not attempt to break locks,
  341. on the philosophy that a stale lock may mean something is badly wrong.
  342. (See
  343. \fILocking in C News\fR for details on locking methods.)
  344. The various programs will either give up, to return later, or wait
  345. patiently for the lock to go away.
  346. If one doesn't keep an eye on things, a problem of some kind can hang up
  347. the news system for quite a while.
  348. Running \fImaint/newswatch\fR once in a while\(emwe recommend a few times
  349. a day\(emwill alert administrators to signs of trouble.
  350. Except on grossly slow systems, C News locks should never hang around for
  351. any great length of time.
  352.